import { ref } from 'vue'
import request from '@/utils/request.js'

//查询当前作业详细
export const select = (taskId) => {
   return request.get('/student/selectTaskManager/' + taskId)
}
//添加作业
export const addTaskManger = (taskManger) => {
   return request.post("/student/uptask", taskManger)
}
//添加作业保存到redis
export const addTaskSave = (taskSave) => {
   return request.post("/student/insertTaskRedis", taskSave)
}
//从redis中取出当前用户保存的作业
export const selectTaskSave = (taskId) => {
   return request.get('/student/getTaskRedis/' + taskId)
}
//上传图片或附件
export const addImage = (file) => {
   const formData = new FormData();
   // 假设 fileList 是包含文件对象的数组
   file.forEach(file1 => {
      formData.append('file', file1.raw, file1.name);
   });
   return request.post('/student/upload', formData, {
      headers: {
         'Content-Type': 'multipart/form-data'
      }
   });
}

//查询当前作业详细
export const selectTaskManagerByTaskId = (taskId) => {
   return request.get('/student/selectTaskManagerByTaskId/' + taskId)
}

//修改提交状态
export const updateCommit = (id) => {
   return request.post('/student/updateCommit/' + id)
}